<extend name="common:base" />
<block name="body">
    <div class="wrapper wrapper-content animated fadeInRight" style="min-height: 250px;">
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        编辑产品
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-12">
                                <form role="form" class="ajaxform form-horizontal" action="{:U('admin/shopproduct/usave')}"  method="post">
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label"><span style="color:#F77DA6;">*</span>产品名称</label>
                                        <div class="col-sm-10">
                                            <input class="form-control"  type="text"   name="name" value="{$product.name}" style="max-width:300px;">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label"><span style="color:#F77DA6;">*</span>所属栏目</label>
                                        <div class="col-sm-10">
                                            <select class="form-control" name="typeid" style="max-width:300px;" >
                                                <option value="0">请选择</option>
                                                {$type_list}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">是否推荐</label>
                                        <div class="col-sm-10" style="line-height: 33px; height: 33px;">

                                            <input class="radio i-checks" type="radio" name="is_recommend" <if condition="$product.is_recommend eq 1">checked</if> value="1"> 是

                                            <input class="radio i-checks" type="radio" name="is_recommend" <if condition="$product.is_recommend eq 0">checked</if> value="0" > 否
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">所需积分</label>
                                        <div class="col-sm-10">
                                            <input class="form-control"  type="text"   name="price" value="{$product.price}" style="max-width:300px;">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">市场价格</label>
                                        <div class="col-sm-10">
                                            <input class="form-control"  type="text"   name="market_price" value="{$product.market_price}" style="max-width:300px;">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">限住人数</label>
                                        <div class="col-sm-10">
                                            <input class="form-control"  type="text"   name="max_num" value="{$product.max_num}" style="max-width:300px;">
                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">年预定次数</label>
                                        <div class="col-sm-10">
                                            <input class="form-control"  type="text"   name="order_num" value="{$product.order_num}" style="max-width:300px;">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">缩略图</label>
                                        <div class="col-sm-10">
                                            <div id="uploader-demo-pc">
                                                <!--用来存放item-->
                                                <div class="file-item-pc">
                                                    <img class="img" src="{$product.litpic}" onerror="this.src='__PUBLIC__/admin/img/no_img.jpg'" width="110px" height="100px" >
                                                    <div class="info" style="display:none;"></div>
                                                    <input type="hidden" class="img_path_pc" name="litpic" value="{$product.litpic}">
                                                </div>
                                                <div id="filePicker-pc">选择图片</div>
                                            </div>
                                        </div>
                                    </div>

                                    <notempty name="product.img_arr">
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">产品已上传图片</label>
                                        <div class="col-sm-10">
                                            <foreach name="product.img_arr" item="vo" key="k">
                                                <div class="tj" id="li_{$k}">
                                                    <img src="{$vo}" width="102px" height="102px">
                                                    <input type="hidden" id="li_path_{$k}" name="img[]" value="{$vo}">
                                                    <button type="button" style="margin-left: 35px;margin-top:5px;" onclick="del_li({$product.id},{$k})">删除</button>
                                                </div>
                                            </foreach>
                                        </div>
                                    </div>
                                    </notempty>

                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">产品图片集</label>
                                        <div id="uploader_product" class="pic_box">
                                            <!--用来存放item-->
                                            <div id="fileList1" class="uploader-list"></div>
                                            <div id="filePicker_product" style='margin-left: 100px;margin-top: -30px;' >选择图片</div>

                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">所在地区</label>
                                        <div class="col-sm-10">
                                            <select class="form-control" name="province_id" id="province_id" style="max-width:150px;float:left;">
                                                <option value="0">请选择</option>
                                                <volist name="districts" id="vo" >
                                                    <option value="{$vo.id}" <if condition="$vo.id eq $product['province_id']">selected </if> >{$vo.name}</option>
                                                </volist>
                                            </select>
                                            <select class="form-control" id="city_id"  name="city_id"  style="max-width:150px;float:left;margin-left: 10px;">
                                                <option value="0">请选择</option>
                                                <volist name="cities" id="vo" >
                                                    <option value="{$vo.id}" <if condition="$product.city_id eq $vo['id']">selected</if> >{$vo.name}</option>
                                                </volist>
                                            </select>
                                            <select class="form-control" id="area_id"  name="area_id"  style="max-width:150px;float:left;margin-left: 10px;">
                                                <option value="0">请选择</option>
                                                <volist name="areas" id="vo" >
                                                    <option value="{$vo.id}" <if condition="$product.area_id eq $vo['id']">selected</if> >{$vo.name}</option>
                                                </volist>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">详细地址</label>
                                        <div class="col-sm-10">
                                            <input class="form-control"  type="text"   name="address" value="{$product.address}"  style="max-width:300px;">
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">更新时间</label>
                                        <div class="col-sm-10">
                                            <input class="form-control"  type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"  name="updated_at" value="{$product.updated_at}"  style="max-width:300px;">
                                        </div>
                                    </div>

                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">入住须知</label>
                                        <div class="col-sm-10">
                                            <textarea class="form-control" name="description" style="max-width:600px;height: 150px;" >{$product.description}</textarea>
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label  class="col-sm-2 control-label">基地详情</label>
                                        <div class="col-sm-10">
                                            <script type="text/plain" id="editor" name="content" style="width:95%;height:300px;">{$product.content}</script>
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <div class="col-sm-offset-2 col-sm-10">
                                            <input type="hidden" value="{$product.id}" name="id">
                                            <button type="submit" class="btn btn-w-m btn-info"><i class="fa fa-check"></i>&nbsp;提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                            <!-- /.col-lg-6 (nested) -->
                            <div class="col-lg-6">

                            </div>
                            <!-- /.col-lg-6 (nested) -->
                        </div>
                        <!-- /.row (nested) -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
    </div>

</block>
<block name="footer">
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/datepicker/WdatePicker.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/webuploader_many/upload_img.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/webuploader/upload_single.js"></script>
    <!--单图上传-->
    <script type="text/javascript" src="__PUBLIC__/js/webuploader/webuploader.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/js/webuploader/webuploader.css">
    <link rel="stylesheet" href="__PUBLIC__/js/webuploader/demo.css">
    <script>
        upload_single('#filePicker-pc','file-item-pc','img_path_pc', '{:U("Common/upload")}','110','100')
    </script>

    <script type="text/javascript" src="__PUBLIC__/js/webuploader_many/webuploader.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/js/webuploader_many/webuploader.css">
    <link rel="stylesheet" href="__PUBLIC__/js/webuploader_many/demo.css">
    <script>
        upload_img('#filePicker_product','#uploader_product',"file-item-li thumbnail","img[]",'{:U("Common/upload")}')
    </script>
    <script>
        var ue = UE.getEditor('editor',{
            autoHeightEnabled: true,
            autoFloatEnabled: true,
            //initialFrameWidth: 373,
            initialFrameHeight:668,
            toolbars: [
                ['fullscreen', 'source', 'undo', 'redo','simpleupload','insertvideo','justifyleft','justifyright','justifycenter','justifyjustify','bold', 'italic', 'underline', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc'],
            ]
        });

        // 选择不同的省的时候
        $("#province_id").change(function(){
            var province_id = $("#province_id").val();
            if (province_id != 0) {
                $.ajax({
                    type: "POST",
                    url: "{:U('admin/common/getcity')}",
                    data: "province_id="+province_id,
                    success: function(msg){
                        $("#city_id").css("display", "");
                        $("#city_id").empty();
                        $("#city_id").append(msg);
                    }
                });
            } else {
                $("#city_id").css("display", "none").empty();
            }
        });
        // 选择不同的城市的时候
        $("#city_id").change(function(){
            var city = $("#city_id").val();
            if (city != 0) {
                $.ajax({
                    type: "POST",
                    url: "{:U('admin/common/getarea')}",
                    data: "city_id=" + city,
                    success: function (msg) {
                        $("#area_id").css("display", "");
                        $("#area_id").empty();
                        $("#area_id").append(msg);
                    }
                });
            }else{
                $("#area_id").css("display", "none").empty();
            }
        });

        function del_li(id,num){
                var path=$('#li_path_'+num).val()
                var msg='确定删除吗？'
                layer.confirm(msg, {
                            btn: ['确定','取消'], //按钮
                        }, function(){
                            $.post("{:U('del_img')}", {type:'extra_licence',id:id,path:path},
                                    function(data){
                                        msg_url(data.info)
                                        if(data.status=="1"){
                                            $('#li_'+num).remove()
                                        }

                                    }, "json");
                        }
                );
        }
    </script>
</block>
